/*
 * Copyright 2017 JessYan
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.dindang.checkline.mvp.model.api.service;

import com.dindang.checkline.mvp.model.api.Api;
import com.dindang.checkline.mvp.model.entity.BaseResponse;
import com.dindang.checkline.mvp.model.entity.CheckItemEntity;
import com.dindang.checkline.mvp.model.entity.CheckLineEntity;
import com.dindang.checkline.mvp.model.entity.LineDetailEntity;
import com.dindang.checkline.mvp.model.entity.TaskDetail;

import java.io.File;
import java.io.InputStream;
import java.util.List;

import io.reactivex.Observable;
import retrofit2.Retrofit;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.Headers;
import retrofit2.http.POST;

/**
 * ================================================
 * 展示 {@link Retrofit#create(Class)} 中需要传入的 ApiService 的使用方式
 * 存放关于用户的一些 API
 * <p>
 * Created by JessYan on 08/05/2016 12:05
 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * ================================================
 */
public interface CommonService {
    String HEADER_API_VERSION = "Content-Type: application/x-www-form-urlencoded; charset=UTF-8";

    /**
     * 查询任务单详情listInspectPoint
     * @return
     */
    @Headers({"Domain-Name: " + Api.APP_NAME, HEADER_API_VERSION})
    @FormUrlEncoded
    @POST("inspect/getPlanRecordDetail.do")
    Observable<BaseResponse<TaskDetail>> quertTaskDetail(
            @Field("recordid") String recordid
    );


    /**
     * 开始接单
     * @return
     */
    @Headers({"Domain-Name: " + Api.APP_NAME, HEADER_API_VERSION})
    @FormUrlEncoded
    @POST("inspect/inspectReceipt.do")
    Observable<BaseResponse> changeStatus(
            @Field("id") String id,
            @Field("officerId") String officerId
            );

    /**
     * 查询巡检路线,巡检点列表
     * @return
     */
    @Headers({"Domain-Name: " + Api.APP_NAME, HEADER_API_VERSION})
    @FormUrlEncoded
    @POST("inspect/listInspectPoint.do")
    Observable<BaseResponse<CheckLineEntity>> quertCheckLine(
            @Field("id") String id);

    /**
     * 开始巡检
     * @return
     */
    @Headers({"Domain-Name: " + Api.APP_NAME, HEADER_API_VERSION})
    @FormUrlEncoded
    @POST("inspect/startInspection.do")
    Observable<BaseResponse> submitStart(
            @Field("id") String id,
            @Field("dExecute") String dExecute,
            @Field("officerId") String officerId
            );

    /**
     * 查看巡检点详情，巡检项列表
     * @return
     */
    @Headers({"Domain-Name: " + Api.APP_NAME, HEADER_API_VERSION})
    @FormUrlEncoded
    @POST("inspect/getInspectPoint.do")
    Observable<BaseResponse<CheckItemEntity>> queryCheckItem(
            @Field("id") String id);

    /**
     * 提交巡检项详情
     * @return
     */
    @Headers({"Domain-Name: " + Api.APP_NAME, HEADER_API_VERSION})
    @FormUrlEncoded
    @POST("inspect/inspectExceptionItem.do")
    Observable<BaseResponse> submitItemDetail(
            @Field("recordItemId") String recordItemId,
            @Field("status") String status,
            @Field("excDesc") String excDesc,
            @Field("cPhoto") List<byte[]> cPhoto,
            @Field("reMark") String reMark,
            @Field("dModifyTime") String dModifyTime,
            @Field("officerId") String userId
            );

    /**
     * 获取巡检概况详情
     * @return
     */
    @Headers({"Domain-Name: " + Api.APP_NAME, HEADER_API_VERSION})
    @FormUrlEncoded
    @POST("inspect/inspectSurvey.do")
    Observable<BaseResponse<LineDetailEntity>> queryLineDetail(
            @Field("recordId") String id);

    /**
     * 异常结束
     * @return
     */
    @Headers({"Domain-Name: " + Api.APP_NAME, HEADER_API_VERSION})
    @FormUrlEncoded
    @POST("inspect/inspectException.do")
    Observable<BaseResponse> submitError(
            @Field("recordId") String recordId,
            @Field("cPhoto") List<byte[]> reason,
            @Field("reMark") String reMark,
            @Field("dClose") String dClose,
            @Field("officerId") String userId
    );

}